/*
 * Copyright (C) 2016  Nicola Spanti (RyDroid) <dev@nicola-spanti.info>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */


#ifndef PLANET_WARS_2D_RT_CORE_OBSERVERS_H
#define PLANET_WARS_2D_RT_CORE_OBSERVERS_H


#include "PlanetWars2dRT-core/utils/observer_essential.h"
#include "PlanetWars2dRT-core/utils/vector_generic.h"


DEFINE_VECTOR_GENERIC_STATIC(observer_t)

typedef vector_observer_t observers_t;


EXTERN_C_BEGIN


void
observers_init_first_time_only(observers_t* observers);

void
observers_destructor(observers_t* observers);

size_t
observers_get_nb_unsafe(const observers_t* observers);

size_t
observers_get_nb(const observers_t* observers);

bool
observers_add(observers_t* observers,
	      const observer_t* an_observer);

bool
observers_remove_without_order(observers_t* observers,
			       const observer_t* an_observer);

bool
observers_remove_with_order(observers_t* observers,
			    const observer_t* an_observer);

void
observers_clear(observers_t* observers);

void
observers_notify(observers_t* observers,
		 void* an_observable,
		 void* data);


EXTERN_C_END


#endif
